home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
fractals
/
sman
/
lib
/
smanlb.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-17
|
23KB
|
1,010 lines
#include "functions.h"
#include "exec/types.h" /*Needed for SOFFSET macro*/
#include "exec/execbase.h"
#include "exec/tasks.h"
#include "exec/memory.h"
#include "exec/ports.h"
#include "clib/graphics_protos.h"
#include "graphics/view.h"
#include "graphics/gfx.h"
#include "graphics/gfxbase.h"
#include "graphics/gfxmacros.h"
#include "graphics/rastport.h"
#include "intuition/intuitionbase.h"
#include "intuition/intuition.h"
#include "intuition/preferences.h"
#include "libraries/dos.h"
#include "libraries/dosextens.h"
#include "stdio.h"
#include "exec/io.h"
#include "iff/iff.h"
#include "iff/ilbm.h"
double XWidth,XHeight,XCenter,YCenter,HWidth,HHeight,Factor,xRel,yRel,Zr,Zi,Z2;
double Zr2,Zi2,Limit,FP7,Two;
double LastX,LastY,LastLim,LastFactor;
LONG xtemp,ytemp,MaxCnt,CurCnt,XC,YC,LeftEdge,RightEdge,NearEdge,FarEdge;
LONG S1Height,S1Width,MltPlr;
ULONG *PlnPtr;
BPTR FileHandle;
#define Pf_Size 0xe8
#define ScnFlg 0x1;
#define LacFlg 0x2;
#define ChdFlg DefFlg | CHECKIT | CHECKED
#define ChkFlg DefFlg | CHECKIT
CmpFlg = MOUSEBUTTONS | MENUPICK;
MyFlag = NOCAREREFRESH|REPORTMOUSE|BORDERLESS;
MenFlg = MENUENABLED | MIDRAWN;
DefFlg = ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP;
struct Library *DOSBase;
struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
struct ExecBase *SysBase;
struct Gadget *GadStuff;
struct NewScreen ns;
struct NewWindow nw;
BYTE CurrentXOffset;
BYTE CurrentYOffset;
UBYTE Title[] = " Julian Explorer";
UBYTE *WindowName;
SHORT SWidth,SHeight;
USHORT MyView,SUFlag,SysFlag,ScnSts,OvsChk,LacChk,LacMod,NLcChk,MenVal,NrmChk;
struct Screen *IntScreen;
struct Screen *WBScreen;
struct Window *InfoWindow;
struct Window *IntWindow;
struct MsgPort *MyPort,*IntPort;
struct RastPort *MyRasta,*WBRast,*CWRast;
struct ViewPort VPorta,VPortb;
struct Preferences MyNewPrefs,*CurPrefs;
struct Menu Menu1,Menu2,Menu3,Menu4;
struct MenuItem *MIStruct;
struct IntuiText *ITStruct;
struct MenuItem MI11,MI12,MI13,MI14;
struct MenuItem MI21,MI22,MI23,MI24;
struct MenuItem MI31,MI32,MI33,MI34;
struct MenuItem MI41,MI42,MI43,MI44;
struct IntuiText IT11,IT12,IT13,IT14;
struct IntuiText IT21,IT22,IT23,IT24;
struct IntuiText IT31,IT32,IT33,IT34;
struct IntuiText IT41,IT42,IT43,IT44;
struct PLANEPTR *PlanePtrA,*PlanePtrB;
static char Err020[] = "Sorry, but this Mandelbrot Generator requires both a 68881 and a 68020!";
static char Err021[] = "Use SManLb as a slow alternative!";
static char Message[] = "by David M. McKinstry";
static char Mesag2[] = "Copyright ";
UBYTE Mesag2b[] = 0xa9;
UBYTE Comma[] = 0x2c;
static char Mesag2c[] = " 1989-91";
static char Mesag3[] = "System Hardware: ";
static char Mesag4[] = "Use the menu options on the Custom Screen to change the following parameters!";
static char Mesag5[] = "Click on the Close Gadget to bring the Custom Screen forward!";
static char Mesag6[] = "(Note: This window won't be closed, just hidden.)";
static char Mesag7[] = "To return to this WorkBench Screen, select 'About' from the SManLb menu!";
static char ScrMsg[] = "Screen center is at ";
static char ChpMsg[] = "Chip Memory Free = ";
static char ChpEnd[] = " ";
static char FstMsg[] = "Fast Memory Free = ";
static char FstEnd[] = " ";
static char WdtMsg[] = "Screen Width = ";
static char WdtEnd[] = " ";
static char HgtMsg[] = "Screen Height = ";
static char HgtEnd[] = " ";
static char MagMsg[] = "Magnification = ";
static char MagEnd[] = " ";
static char XPos[] = "x = ";
static char XPsEnd[] = " ";
static char YPos[] = "y = ";
static char YPsEnd[] = " ";
static char CntMsg[] = "Maximum Count = ";
static char CntEnd[] = " ";
static char HavMsg[] = "You have at least a 68020 and 68881. Why not use SManCP?";
static char StrngBuffer[200];
SHORT VertPos;
USHORT CTable[] = {0,0xf00,0xff0,0x3f8,0x5ea,0xf3a,0x0de,0xf80,0x9f0,0x7df,0x69f,
0x00f,0xf2e,0xc0e,0x60e,0x607};
SHORT PolyTab[10];
SHORT *PolyPnt;
SHORT DeltaX,DeltaY;
SHORT x1,y1,x2,y2;
ULONG IMClass;
ScanOn()
{
NrmChk = ChkFlg;
OvsChk = ChdFlg;
SWidth = 704;
SHeight = 478;
S1Width = 703;
S1Height = 477;
XC = 352;
YC = 239;
NearEdge = 0;
LeftEdge = 0;
RightEdge = 704;
FarEdge = 478;
ScnSts = 1; /* Indicate overscan on */
}
ScnOff()
{
NrmChk = ChdFlg;
OvsChk = ChkFlg;
SWidth = 640;
SHeight = 400;
S1Width = 639;
S1Height = 399;
XC = 320;
YC = 199;
NearEdge = 0;
LeftEdge = 0;
RightEdge = 640;
FarEdge = 400;
ScnSts = 0; /* Change to no overscan */
}
LaceOff()
{
MyView = HIRES;
LacChk = ChkFlg;
NLcChk = ChdFlg;
LacMod = 0;
SHeight = SHeight/2;
S1Height = SHeight;
--S1Height;
FarEdge = FarEdge/2;
}
LaceOn()
{
MyView = HIRES | LACE;
LacChk = ChdFlg;
NLcChk = ChkFlg;
LacMod = 1;
}
ScnSet()
{
if (SUFlag & 0x2) {
LaceOn();
}
else LaceOff();
}
ViewSet()
{
if (SUFlag & 0x1) { /* See if Overscan flag set */
ScanOn();
ScnSet();
}
else {
ScnOff();
ScnSet();
}
}
SetLim()
{
Limit = Two*Factor;
Limit = Limit*Limit;
}
InitPar()
{
XWidth = SWidth;
XHeight = SHeight;
HWidth = XC;
XCenter = XC;
HHeight = YC;
YCenter = YC;
SetLim();
}
HasFast()
{
ViewSet();
Factor = MltPlr;
Factor = MltPlr;
InitPar();
}
void ITInit(Item,NamePtr)
struct IntuiText *Item;
UBYTE *NamePtr;
{
Item -> IText = NamePtr;
Item -> BackPen = 3;
Item -> FrontPen = 5;
Item -> DrawMode = JAM1;
}
MIInit(Item,NxtItem,TEdge,Cmd,ITItem,Width)
struct MenuItem *Item,*NxtItem;
APTR ITItem;
SHORT TEdge,Width;
BYTE Cmd;
{
Item -> Command = Cmd;
Item -> TopEdge = TEdge;
Item -> NextItem = NxtItem;
Item -> ItemFill = (APTR)ITItem;
Item -> Flags = (USHORT)DefFlg;
Item -> Height = 9;
Item -> Width = Width;
}
void MenuInit(MenuStruct,NxtMenu,NamePtr,LEdge,MWidth)
struct Menu *MenuStruct,*NxtMenu;
SHORT LEdge,MWidth;
BYTE *NamePtr;
{
MenuStruct -> NextMenu = NxtMenu;
MenuStruct -> Width = MWidth;
MenuStruct -> Height = 9;
MenuStruct -> LeftEdge = LEdge;
MenuStruct -> TopEdge = 0;
MenuStruct -> MenuName = NamePtr;
MenuStruct -> Flags = MenFlg;
}
void ScreenSet()
{
SHORT MWidth,MHeight,LEdge,TEdge;
UBYTE MICommand;
struct Menu *MenStrct;
BOOL Test;
ns.LeftEdge = 0;
ns.TopEdge = 0; /*Was 20 */
ns.Width = SWidth;
ns.Height = SHeight;
ns.DetailPen = 0;
ns.BlockPen = 1;
ns.Depth = 4;
ns.ViewModes = MyView;
IntScreen = (struct Screen *)OpenScreen( &ns );
PlanePtrA = (struct PLANEPTR *)(IntScreen -> BitMap.Planes);
MyRasta = &(IntScreen -> RastPort);
VPorta = IntScreen -> ViewPort;
LoadRGB4(&VPorta,&CTable[0],16);
if (ScnSts) {
MyNewPrefs.ViewXOffset = 0xde;
MyNewPrefs.ViewYOffset = 0xed;
}
else {
MyNewPrefs.ViewXOffset = CurrentXOffset;
MyNewPrefs.ViewYOffset = CurrentYOffset;
}
SetPrefs(&MyNewPrefs,Pf_Size,FALSE);
nw.Title = NULL;
nw.LeftEdge = 0;
nw.TopEdge = 0;
nw.Width = SWidth;
nw.Height = SHeight;
nw.DetailPen = 5;
nw.BlockPen = 2;
/*nw.IDCMPFlags = GADGETUP | MENUPICK;*/
nw.IDCMPFlags = CmpFlg;
nw.Type = CUSTOMSCREEN;
nw.Flags = MyFlag; ACTIVATE | SMART_REFRESH;
nw.FirstGadget = NULL;
nw.CheckMark = NULL;
nw.Screen = IntScreen;
nw.BitMap = NULL;
nw.MinWidth = 320;
nw.MinHeight = 100;
nw.MaxWidth = SWidth;
nw.MaxHeight = SHeight;
IntWindow = (struct Window *)OpenWindow( &nw );
/* Get associated information about Int window */
/* GadStuff = IntWindow -> FirstGadget;*/
CWRast = IntWindow -> RPort;
SetRast(CWRast,0);
IntPort = IntWindow -> UserPort;
/* Template is
MenuInit(&Menu1,&Menu2,"Strng",LEdge,MWidth);
*/
MenuInit(&Menu1,&Menu2,"SManLb",20,100);
Menu1.FirstItem = &MI11;
MIInit(&MI11,&MI12,0,0x41,&IT11,150);
MIInit(&MI12,&MI13,9,0x52,&IT12,150);
MIInit(&MI13,&MI14,18,0x53,&IT13,150);
MIInit(&MI14,0,27,0x51,&IT14,150);
ITInit(&IT11,"About");
ITInit(&IT12,"Redraw(Same P)");
ITInit(&IT13,"Save");
ITInit(&IT14,"Quit");
MenuInit(&Menu2,&Menu3,"View Mode",180,130);
Menu2.FirstItem = &MI21;
MIInit(&MI21,&MI22,0,0x4c,&IT21,150);
MIInit(&MI22,&MI23,9,0x43,&IT22,150);
MIInit(&MI23,&MI24,18,0x4d,&IT23,150);
MIInit(&MI24,0,27,0x4e,&IT24,150);
ITInit(&IT21," Lace On");
ITInit(&IT22," Lace Off");
ITInit(&IT23," Ove